var operationLogApp = new Vue({
    el: '#operationLogApp',
    data: {
        operationFilterParameters: {
            currentPage: 1,
            pageSize: 10,
            startDate: "",
            endDate: "",
            searchKey: "",
        },
        operationLogList: [],
        total: 0,
        current: 1,
        pages: 0,
        size: 0,
    },
    mounted:  function(){
        this.initData()
    },
    methods: {
        initData: function() {
            this.getOperationLogList()
        },
        clear: function(event) {
            this.operationFilterParameters.startDate = '';
            this.operationFilterParameters.endDate = '';
            this.operationFilterParameters.searchKey = '';
            // this.getOperationLogList()
        },
        search: function(event) {
            this.operationFilterParameters.startDate = document.getElementById('startDate').value;
            this.operationFilterParameters.endDate = document.getElementById('endDate').value;
            this.operationFilterParameters.searchKey = this.operationFilterParameters.searchKey.trim()
            this.operationFilterParameters.currentPage = 1
            this.getOperationLogList()
        },
        // 获取操作日志列表
        getOperationLogList: function() {
            var _self = this;
            var requestUrl = VUE_UTIL.buildRequestUrl('/operationLog/list', this.operationFilterParameters);
            VUE_UTIL.getAxiosInstance().get(requestUrl)
                .then(function(response){
                    _self.operationLogList = response.data.data.records;
                    _self.total = response.data.data.total
                    _self.current = response.data.data.current
                    _self.pages = response.data.data.pages
                    _self.initPaging();
                })
        },
        // 初始化分页显示
        initPaging: function() {
            var _self = this;
            layui.use(['laypage', 'layer'], function () {
                var laypage = layui.laypage;
                laypage({
                    cont: 'turn-page',
                    curr: _self.current || 1,
                    pages: _self.pages,
                    skin: '#457fe6',
                    skip: true,
                    jump: function (obj, first) {
                        if (!first) {
                            _self.operationFilterParameters.currentPage = obj.curr
                            _self.getOperationLogList()
                        }
                    }
                });
            });
        }
    },
    // 格式化日期显示
    filters: {
        formatDate: function (dateStr) {
            return VUE_UTIL.formatDate(dateStr)
        }
    }
})